package com.cqc.rxjava01.Http;

import com.cqc.rxjava01.entity.BaseResult;
import com.cqc.rxjava01.entity.CommonResult;
import com.cqc.rxjava01.entity.User;
import com.cqc.rxjava01.entity.RegisterResponse;

import java.util.Map;

import io.reactivex.Observable;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;

/**
 * Created by cui on 2017/8/16.
 * Api
 */

public interface UserApi {

    @GET("loadAllOrder.a")
    Call<String> getAllOrders(@Query("driverTel") String driverTel);

    @GET("loadAllOrder.a")
    Call<BaseResult> getAllOrders2(@Query("driverTel") String driverTel);

    /*；用path老是报错，不知道怎么解决。用query可以
    @GET("loadAllOrder.a?driverTel={driverTel}")
    Call<String> getAllOrders(@Path("driverTel") String driverTel);*/
    //404
    @POST("loadAllOrder.a/{driverTel}")
    Call<String> getAllOrders3(@Path("driverTel") String driverTel);


    @POST("register")
    Observable<User> register(@Body User user);

    /**
     * 传递user，服务端user=null，没找到原因
     * @param user
     * @return
     */

    @POST("login2")
    Observable<BaseResult> login2(@Body User user);

    @POST("login")
    Observable<BaseResult> login(@Query("username")String username, @Query("password") String password);

    //服务端：login4(@RequestBody User user)
    @POST("login4")
    Observable<CommonResult<User>> login4(@Body User user);


    @POST("")
    @FormUrlEncoded
    Observable<CommonResult<String>> upFile(@FieldMap Map<String,Object> map);

}
